package com.gongJiao.service.impl;

import com.gongJiao.Vo.OpinionVo;
import com.gongJiao.Vo.PageCondition;
import com.gongJiao.entity.Opinion;
import com.gongJiao.mapper.OpinionMapper;
import com.gongJiao.service.OpinionService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author ${author}
 * @since 2021-12-25
 */
@Service
public class OpinionServiceImpl extends ServiceImpl<OpinionMapper, Opinion> implements OpinionService {
    @Autowired
    OpinionMapper opinionMap;

    /**
     * 后台分页查询意见列表信息集合
     * @param pageCondition
     * @return
     */
    @Override
    public List<OpinionVo> getOpinionList(PageCondition pageCondition) {
        return opinionMap.getOpinionList(pageCondition);
    }

    /**
     * 后台分页查询意见列表信息数量
     * @param pageCondition
     * @return
     */
    @Override
    public Integer getCount(PageCondition pageCondition) {
        return opinionMap.getCount(pageCondition);
    }

    /**
     * 删除意见信息
     * @param ids
     */
    @Override
    public void deleteOpinionByIds(String ids) {
        String[] idArray = ids.split(",");
        List idList=new ArrayList<>();
        for (String id : idArray) {
            idList.add(id);
        }
        opinionMap.deleteBatchIds(idList);
    }

    /**
     * 根据id获取意见信息
     * @param id
     * @return
     */
    @Override
    public Opinion getOpinionById(Long id) {
        return opinionMap.selectById(id);
    }
}
